﻿#region License
// /* **************************************************************
// * Copyright (C) intex Consulting GmbH - All Rights Reserved    *
// *--------------------------------------------------------------*
// * Unauthorized copying of this file, via any medium is         *
// * strictly prohibited                                          *
// *--------------------------------------------------------------*
// * Proprietary and confidential                                 *
// *--------------------------------------------------------------*
// * Dissasembling/modifications strictly prohibited!             *
// ***************************************************************/
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using ComHlp.ContentClasses.VirtualControls;
using ComHlp.ContentClasses.VirtualControls.LView;

namespace ComHlp.ContentClasses.FormDef
{
    /// <summary> struct for saving FormDef informations </summary>
    public class FormDefMap : ICloneable
    {
        public FormDefHeader Header { get; set; } = new FormDefHeader();
        public List<ItxField> Fields { get; set; } = new List<ItxField>();
        public List<ItxFieldAddition> UnassignedAdditions { get; set; }
        public List<ItxRectangle> Rectangles { get; set; } = new List<ItxRectangle>();
        public ItxListViewContainer ListViewCont { get; set; }
        public List<ItxFieldAddition> RectangleHeadlines { get; set; }


        object ICloneable.Clone() { return Clone(); }

        public FormDefMap Clone()
        {
            FormDefMap clonedMap = MemberwiseClone() as FormDefMap;
            if (clonedMap == null)
                return null;

            //FormDefHeader header = Header.Clone();
            List<ItxField> clonedFields = new List<ItxField>(Fields.Count);
            clonedFields.AddRange(clonedMap.Fields.Select(x => x.Clone()));
            clonedMap.Fields = clonedFields;

            List<ItxFieldAddition> clonedAdditions = new List<ItxFieldAddition>(UnassignedAdditions.Count);
            clonedAdditions.AddRange(clonedMap.UnassignedAdditions.Select(x => x.Clone()));
            clonedMap.UnassignedAdditions = clonedAdditions;

            List<ItxRectangle> clonedRectangles = new List<ItxRectangle>(Rectangles.Count);
            clonedRectangles.AddRange(clonedMap.Rectangles.Select(x => x.Clone()));
            clonedMap.Rectangles = clonedRectangles;

            // todo lsitview cont

            List<ItxFieldAddition> clonedRectangleHls = new List<ItxFieldAddition>(RectangleHeadlines.Count);
            clonedRectangleHls.AddRange(clonedMap.RectangleHeadlines.Select(x => x.Clone()));
            clonedMap.RectangleHeadlines = clonedRectangleHls;

            return clonedMap;
        }
    }
}